#include <QCoreApplication>
#include <event2/event.h>
#include <event2/listener.h>
#include <iostream>
#include <signal.h>
#include <QDebug>
static timeval t1 = {1,0};
void timer1(int sock,short what,void* arg){
    qDebug() << "[timer1]";
    event* ev = (event*)arg;
    if(!evtimer_pending(ev,&t1)){
        evtimer_del(ev);
        evtimer_add(ev,&t1);
    }
}

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    if(signal(SIGPIPE,SIG_IGN) == SIG_ERR){
        return -1;
    }

    event_base* base = event_base_new();

    if(!base){
        return -1;
    }

    event*ev1 = evtimer_new(base,timer1,event_self_cbarg());
    qDebug() << "1";
    evtimer_add(ev1,&t1);

    event_base_dispatch(base);
    return 0;
}
